<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取当前传输的有关信息</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.curl-multi-getcontent.html">« curl_multi_getcontent</a></li>
      <li style="float: right;"><a href="function.curl-multi-init.html">curl_multi_init »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.curl.html">cURL 函数</a></li>
    <li>获取当前传输的有关信息</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.curl-multi-info-read" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">curl_multi_info_read</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">curl_multi_info_read</span> &mdash; <span class="dc-title">获取当前传输的有关信息</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.curl-multi-info-read-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>curl_multi_info_read</strong></span>(<span class="methodparam"><span class="type"><a href="class.curlmultihandle.html" class="type CurlMultiHandle">CurlMultiHandle</a></span> <code class="parameter">$multi_handle</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter reference">&$queued_messages</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type">array</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   查询多句柄是否有来自个别传输的消息或信息，消息可能包含诸如来自传输的错误代码或者仅是传输已完成之类的信息。
  </p>
  <p class="para">
   重复调用此函数，每次都会返回新结果，返回 <strong><code>false</code></strong> 作为此时没有更多信息可以获取的信号。通过
   <code class="parameter">queued_messages</code> 返回的整数包含当前函数调用后剩余的消息数量。
  </p>
  <div class="warning"><strong class="warning">警告</strong>
   <p class="para">
    返回的资源指向的数据将无法在调用 <span class="function"><a href="function.curl-multi-remove-handle.html" class="function">curl_multi_remove_handle()</a></span> 后继续存在。
   </p>
  </div>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.curl-multi-info-read-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    <dt>
<code class="parameter">multi_handle</code>
</dt>
<dd>
<p class="para">由 
<span class="function"><a href="function.curl-multi-init.html" class="function">curl_multi_init()</a></span> 返回的 cURL 多个句柄。</p></dd>

    
     <dt>
<code class="parameter">queued_messages</code></dt>

     <dd>

      <p class="para">
       仍在队列中的消息数量。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.curl-multi-info-read-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回信息的关联数组，失败时返回 <strong><code>false</code></strong>。
  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong>返回数组的内容</strong></caption>
    
     <thead>
      <tr>
       <th>Key:</th>
       <th>Value:</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td><code class="literal">msg</code></td>
       <td><strong><code>CURLMSG_DONE</code></strong> 常量。其他返回值当前不可用。</td>
      </tr>

      <tr>
       <td><code class="literal">result</code></td>
       <td><strong><code>CURLE_*</code></strong> 常量之一。如果一切都好，将会返回 <strong><code>CURLE_OK</code></strong>。</td>
      </tr>

      <tr>
       <td><code class="literal">handle</code></td>
       <td>cURL 资源类型表明它有关的句柄。</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.curl-multi-info-read-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">multi_handle</code> expects a <span class="classname"><a href="class.curlmultihandle.html" class="classname">CurlMultiHandle</a></span>
  instance now; previously, a <span class="type">resource</span> was expected.
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.curl-multi-info-read-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4202">
    <p><strong>示例 #1 <span class="function"><strong>curl_multi_info_read()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$urls&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"http://www.cnn.com/"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"http://www.bbc.co.uk/"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"http://www.yahoo.com/"<br /></span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$mh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_multi_init</span><span style="color: #007700">();<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$urls&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$url</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">curl_init</span><span style="color: #007700">(</span><span style="color: #0000BB">$url</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">CURLOPT_RETURNTRANSFER</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">curl_multi_add_handle</span><span style="color: #007700">(</span><span style="color: #0000BB">$mh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]);<br />}<br /><br />do&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$status&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_multi_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$mh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$active</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$active</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">curl_multi_select</span><span style="color: #007700">(</span><span style="color: #0000BB">$mh</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(</span><span style="color: #0000BB">false&nbsp;</span><span style="color: #007700">!==&nbsp;(</span><span style="color: #0000BB">$info&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_multi_info_read</span><span style="color: #007700">(</span><span style="color: #0000BB">$mh</span><span style="color: #007700">)))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$info</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}&nbsp;while&nbsp;(</span><span style="color: #0000BB">$active&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;</span><span style="color: #0000BB">$status&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">CURLM_OK</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$urls&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$url</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$res</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">curl_multi_getcontent</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">curl_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]);<br />}<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">curl_multi_info_read</span><span style="color: #007700">(</span><span style="color: #0000BB">$mh</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
array(3) {
  [&quot;msg&quot;]=&gt;
  int(1)
  [&quot;result&quot;]=&gt;
  int(0)
  [&quot;handle&quot;]=&gt;
  resource(5) of type (curl)
}
array(3) {
  [&quot;msg&quot;]=&gt;
  int(1)
  [&quot;result&quot;]=&gt;
  int(0)
  [&quot;handle&quot;]=&gt;
  resource(7) of type (curl)
}
array(3) {
  [&quot;msg&quot;]=&gt;
  int(1)
  [&quot;result&quot;]=&gt;
  int(0)
  [&quot;handle&quot;]=&gt;
  resource(6) of type (curl)
}
bool(false)
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.curl-multi-info-read-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.curl-multi-init.html" class="function" rel="rdfs-seeAlso">curl_multi_init()</a> - 返回一个新cURL批处理句柄</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>